<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>订单详情</title>
<#assign base=request.contextPath  />
     <link href="${base}/css/mui.min.css" rel="stylesheet"/>
    <script type="text/javascript" src="${base}/js/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/Yang/layui/css/layui.css"/>
    <script src="${base}/Yang/layui/layui.all.js"></script>
</head>
<style type="text/css">
    .foot {
        margin: 10px;
    }

    span {
        padding-left: 20px;
     }
    .mui-content{
        padding-top: 44px;
    }
    button{
        border-radius: 5px;
    }
</style>
<body>
<header class="mui-bar mui-bar-nav">
    <h1 class="mui-title">${carPlant}订单详情</h1>
</header>
<div class="mui-content">
    <ul class="mui-table-view">
    <#if info.StartChargeSeqStat==1>
        <li class="mui-table-view-cell">充电订单状态:<span class="mui-badge-inverted">启动中</span></li>
    </#if>
    <#if info.StartChargeSeqStat==2>
        <li class="mui-table-view-cell">充电订单状态:<span class="mui-badge-inverted">充电中</span></li>
    </#if>
    <#if info.StartChargeSeqStat==3>
        <li class="mui-table-view-cell">充电订单状态:<span class="mui-badge-inverted">停止中</span></li>
    </#if>
    <#if info.StartChargeSeqStat==4>
        <li class="mui-table-view-cell">充电订单状态:<span class="mui-badge-inverted">已结束</span></li>
    </#if>
    <#if info.StartChargeSeqStat==5>
        <li class="mui-table-view-cell">充电订单状态:<span class="mui-badge-inverted">未知</span></li>
    </#if>

        <li class="mui-table-view-cell">充电设备接口编码:<span class="mui-badge-inverted">${info.ConnectorID}</span></li>
    <#if info.ConnectorStatus==1>
        <li class="mui-table-view-cell">充电设备接口状态:<span class="mui-badge-inverted">空闲</span></li>
    </#if>
    <#if info.ConnectorStatus==2>
        <li class="mui-table-view-cell">充电设备接口状态:<span class="mui-badge-inverted">占用（未充电）</span></li>
    </#if>
    <#if info.ConnectorStatus==3>
        <li class="mui-table-view-cell">充电设备接口状态:<span class="mui-badge-inverted">占用（充电中） </span></li>
    </#if>
    <#if info.ConnectorStatus==4>
        <li class="mui-table-view-cell">充电设备接口状态:<span class="mui-badge-inverted">占用（预约锁定）</span></li>
    </#if>
    <#if info.ConnectorStatus==255>
        <li class="mui-table-view-cell">充电设备接口状态:<span class="mui-badge-inverted">故障</span></li>
    </#if>
        <li class="mui-table-view-cell">A 相电流:<span class="mui-badge-primary mui-badge-inverted">${info.CurrentA}</span>
        </li>
        <li class="mui-table-view-cell">B 相电流:<span class="mui-badge-success mui-badge-inverted">${info.CurrentB}</span>
        </li>
        <li class="mui-table-view-cell">C 相电流:<span class="mui-badge-warning mui-badge-inverted">${info.CurrentC}</span>
        </li>
        <li class="mui-table-view-cell">A 相电压:<span class="mui-badge-danger mui-badge-inverted">${info.VoltageA}</span>
        </li>
        <li class="mui-table-view-cell">B 相电压:<span class="mui-badge-royal mui-badge-inverted">${info.VoltageB}</span>
        </li>
        <li class="mui-table-view-cell">C 相电压:<span class="mui-badge-red mui-badge-inverted">${info.VoltageC}</span>
        </li>
        <li class="mui-table-view-cell">电池剩余电量:<span class="mui-badge-inverted">${info.Soc}</span></li>
        <li class="mui-table-view-cell">开始充电时间:<span class="mui-badge-inverted">${info.StartTime}</span></li>
        <li class="mui-table-view-cell">本次采样时间:<span class="mui-badge-inverted">${info.EndTime}</span></li>
        <li class="mui-table-view-cell">累计充电量:<span class="mui-badge-inverted">${info.TotalPower}</span></li>
        <li class="mui-table-view-cell">累计电费:<span class="mui-badge-inverted">${info.ElecMoney}</span></li>
        <li class="mui-table-view-cell">累计服务费:<span class="mui-badge-inverted">${info.SeviceMoney}</span></li>
        <li class="mui-table-view-cell">累计总金额:<span class="mui-badge-inverted">${info.TotalMoney}</span></li>
        <li class="mui-table-view-cell">时段数 N:<span class="mui-badge-inverted">${info.SumPeriod}</span></li>
    </ul>
    <div class="foot">
        <button type="button" onclick="stopCharge()" class="mui-btn mui-btn-blue mui-btn-block">结束充电</button>
    </div>
</div>
<script>
    //停止充电
    function stopCharge() {
        layer.load();
        var order = "${info.StartChargeSeq}";
        var connectorID = "${info.ConnectorID}";
        $.ajax({
            url: "${base}/scan/stopCharge",
            type: "post",
            data: {
                order: order,
                connectorID: connectorID
            },
            success: function (data) {
                if (data.StartChargeSeqStat == 3) {
                    alert("正在停止中...")
                    setTimeout(function(){
                        findStopStat();
                    },5000)
                }else{
                    if (data.StartChargeSeqStat == 4) {
                        alert("已结束")
                    }else{
                        alert("订单状态异常  错误代码：" + data.StartChargeSeqStat)
                    }
                    if(data.SuccStat=="1"){
                        alert("操作失败，"+data.FailReason)
                    }
                }



            }

        });
    }

    //查询停止结果
    function findStopStat(){
        var order = "${info.StartChargeSeq}";
        var connectorID = "${info.ConnectorID}";
        var carPlant = "${carPlant}";
        $.ajax({
            url: "${base}/scan/findStopStat",
            type: "post",
            data: {
                order: order,
                connectorID: connectorID,
                carPlant: carPlant
            },
            success: function (data) {
                if(data.startChargeSeqStat==4){
                 alert("已结束充电");
                    closeWindo();
                }else{
                    alert("停止超时..请稍后.."+data.startChargeSeqStat);
                }
            }

        });
    }



    function closeWindo(order) {
        WeixinJSBridge.invoke('closeWindow',{},function(res){

            //alert(res.err_msg);

        });
    }
</script>
</body>
</html>
